package com.nl.list;

import com.nl.list.LinkedList.Node;

public class BackwardKNode {

	public static <T> Node<T>  kNode(LinkedList<T> list,int k){
		if(list==null ||list.phead==null||k<1){
			return null;
		}

		if(list.length <k){
			return null;
		}

		Node<T> first = list.phead,last=list.phead;
		for(int i=0;i<k-1;i++){
			last = last.next;
		}

		while(last.next!=null){
			first=first.next;
			last=last.next;
		}
		return first;
	}
}
